<?php
/**
 * Created by PhpStorm.
 * Author: 芸签cms www.yunqiancms.com
 * User: sun
 * Date: 2022/6/24
 * Time: 4:29 PM
 */
namespace app\backend\modules\sys\services;

use app\common\models\Carousel;
use app\common\models\CarouselItem;

class CarouselService
{
    /**
     * 获取幻灯片列表
     * @param $params
     * @return mixed
     */
    public function getList($params){
        $query = Carousel::site()->select();
        if($params['name']){
            $query->where('name','like','%'.$params['name'].'%');
        }
        $list = $query
            ->orderBy('id', 'desc')
            ->paginate(10);
        return $list;
    }

    /**
     * 获取具体幻灯片列表
     * @param $params
     * @return mixed
     */
    public function getItemList($params){
        $query = CarouselItem::site()->select();
        if($params['title']){
            $query->where('title','like','%'.$params['title'].'%');
        }
        if($params['carousel_id']){
            $query->where('carousel_id',$params['carousel_id']);
        }
        $list = $query
            ->orderBy('display_order', 'desc')
            ->orderBy('id', 'desc')
            ->paginate(10);
        return $list;
    }
}